//
//  BgoodsAdmimTableViewCell.m
//  Distributor
//
//  Created by 主事丫环 on 2019/5/16.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "BgoodsAdmimTableViewCell.h"

@implementation BgoodsAdmimTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.leftBut.layer.masksToBounds = YES;
    self.leftBut.layer.cornerRadius = 14;
    self.leftBut.layer.borderColor = [UIColor colorWithHexString:@"#707070"].CGColor;
    self.leftBut.layer.borderWidth = 1;
    
    self.centerBut.layer.masksToBounds = YES;
    self.centerBut.layer.cornerRadius = 14;
    self.centerBut.layer.borderColor = [UIColor colorWithHexString:@"#707070"].CGColor;
    self.centerBut.layer.borderWidth = 1;
    
    self.rightBUt.layer.masksToBounds = YES;
    self.rightBUt.layer.cornerRadius = 14;
    self.rightBUt.layer.borderColor = [UIColor colorWithHexString:@"#707070"].CGColor;
    self.rightBUt.layer.borderWidth = 1;
    

    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)refash:(BgoodsAdminListModel *)model{
    
//    t UILabel *titleLB;
//    @property (weak, nonatomic) IBOutlet UIImageView *picImage;
//    @property (weak, nonatomic) IBOutlet UILabel *priceLB;
//    @property (weak, nonatomic) IBOutlet UILabel *kucunLB;
//
//    @property (weak, nonatomic) IBOutlet UILabel *xiaoliangLB;
//
//    @property (weak, nonatomic) IBOutlet UIButton *leftBut;
//    @property (weak, nonatomic) IBOutlet UIButton *centerBut;
//    @property (weak, nonatomic) IBOutlet UIButton *rightBUt;
//    @property(nonatomic,copy)void (^myblock)(NSInteger ind);
    
    NSLog(@"%@", model.product_pic);
    
    if ([model.product_pic hasPrefix:@"http"]) {
        [self.picImage sd_setImageWithURL:[NSURL URLWithString:model.product_pic] placeholderImage:defaultImg];
    }else{
        sdimg(self.picImage, model.product_pic);
        
    }
    self.priceLB.text = [NSString stringWithFormat:@"¥%@",model.product_price];

    self.titleLB.text = [NSString stringWithFormat:@"%@",model.product_name];
    self.kucunLB.text = [NSString stringWithFormat:@"库存:%@",model.Stock];
    self.xiaoliangLB.text = [NSString stringWithFormat:@"销量:%@",model.cellCount];
    self.leftBut.hidden = NO;
    self.centerBut.hidden = NO;
    self.rightBUt.hidden = NO;

    if ([model.product_state integerValue]  == 1) {
        //上架
        self.leftBut.hidden = YES;
        [self.centerBut setTitle:@"下架" forState:(UIControlStateNormal)];
    }if ([model.product_state integerValue]  == 2){
        
        [self.centerBut setTitle:@"上架" forState:(UIControlStateNormal)];

    }
    
    
}




- (IBAction)leftActinon:(UIButton *)sender {
    if (self.myblock) {
        self.myblock(0);
    }
}
- (IBAction)centerAction:(UIButton *)sender {
    if (self.myblock) {
        self.myblock(1);
    }
}
- (IBAction)rightAction:(UIButton *)sender {
    if (self.myblock) {
        self.myblock(2);
    }
}

@end
